With the 'rightclicked' attribute you can set a script file that is called when user rightclicks the block. You can use world, origin and player for your script.
rightclicked="loader.loadScript('xyz.script');";